/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package modele;

/**
 * @author Hadrien
 */

public class ParisVisite extends Order{
    override public var description = bind "{quantity} Ticket Paris Visite\nZone : {zone} / {if (reduceFare) "Tarif réduit" else "Plein tarif"}\nJours: {duration}";
    public var reduceFare: Boolean = false on replace {computePrice()};
    public var duration: Integer = 1 on replace {computePrice()};
    public var zone: String = "1 - 3" on replace {computePrice()};
    init {
        if (zone == "1 - 3") {
            if (reduceFare) {
                price = if (duration==1) 4.65 else if (duration==2) 7.6 else if (duration==3) 10.35 else if (duration == 5) 14.95 else 0;
            } else {
                price = if (duration==1) 9 else if (duration==2) 14.7 else if (duration==3) 20.0 else if (duration == 5) 28.9 else 0;
            }
         }
         else if (zone == "1 - 6") {
            if (reduceFare) {
                price = if (duration==1) 9.8 else if (duration==2) 14.95 else if (duration==3) 20.95 else if (duration == 5) 25.6 else 0;
            } else {
                price = if (duration==1) 18.9 else if (duration==2) 28.9 else if (duration==3) 40.5 else if (duration == 5) 49.4 else 0;
            }
         }
         else {
             price=0;
        }
        name = "Paris visite ticket";
    }

    override public function deliver () : Void {
        for (i in [1..quantity]) {
            println("Print a {name} for {duration} day{if (duration==1) "" else "s"}  and zone {zone} {if (reduceFare) "reduce fare" else "full fare"})");
        }
    }
    function computePrice() : Void {
        if (zone == "1 - 3") {
            if (reduceFare) {
                price = if (duration==1) 4.65 else if (duration==2) 7.6 else if (duration==3) 10.35 else if (duration == 5) 14.95 else 0;
            } else {
                price = if (duration==1) 9 else if (duration==2) 14.7 else if (duration==3) 20.0 else if (duration == 5) 28.9 else 0;
            }
         }
         else if (zone == "1 - 6") {
            if (reduceFare) {
                price = if (duration==1) 9.8 else if (duration==2) 14.95 else if (duration==3) 20.95 else if (duration == 5) 25.6 else 0;
            } else {
                price = if (duration==1) 18.9 else if (duration==2) 28.9 else if (duration==3) 40.5 else if (duration == 5) 49.4 else 0;
            }
         }
         else {
             price=0;
        }
    }

}
